﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common;
using DAL;
using Model;
namespace UI.system.page.product
{
    public partial class categoryadd : BaseAdmin
    {
        public CategoryInfo info = new CategoryInfo();
        public CategoryInfo parent = new CategoryInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = JobRequest.GetRequestInt("id");
            int parentid = JobRequest.GetRequestInt("parentid");
            if (id != 0)
            {
                info = CategoryDAL.FindOneByID(id);
                if (info.ParentID > 0)
                {
                    parent = CategoryDAL.FindOneByID(info.ParentID);
                }
                else
                {
                    parent.ID = 0;
                    parent.Name = "无上级";
                }

            }else
            {
                if (parentid > 0)
                {
                    parent = CategoryDAL.FindOneByID(parentid);
                    info.Sort = CommonDAL.MaxSort("category", parentid);
                }
                else
                {
                    info.Sort = CommonDAL.MaxSort("category", 0);
                    parent.ID = 0;
                    parent.Name = "无上级";
                }
            }
            
        }
    }
}